import React from 'react';
import { Carousel, WingBlank } from 'antd-mobile';

import $ from 'jquery';
import { HashRouter as Router,Route,Link,NavLink,Redirect,Switch} from 'react-router-dom';
import '../css/productlist.css';



class Productlist extends React.Component{
	constructor(props){
		super(props)
        this.state = {
            plist:[]
        }
    }
    profh(){
		this.props.history.push('/home')
	}

	render(){
		return(
			<div className="pro-da">
                
                    <header className="pro-header">
                        <span className="pro-fanhui" onClick={this.profh.bind(this)}>《</span><span> 全部商品</span>
                    </header>
                    <div className="pro-section">
                        <ul className="pro-list">
                            {
                                	this.state.plist.map(function(item,i){
                                        return(
                                            <li>
                                                <NavLink to={"/detail/"+item.pid}>
                                                    <div><img src={item.pimg}/></div>
                                                    <div>
                                                        <p>{item.pname}</p>
                                                        <p>{item.pdesc}</p>
                                                        <p><span>建议零售价：￥{item.pprice}</span><button>加入购物车</button></p>
                                                    </div>
                                                </NavLink>
                                            </li>
                                        )
                                    })
                            }
                           
                        </ul>
                    </div>
            
			</div>
		)
    }
    componentWillMount(){
		var _this=this;
		$.ajax({
			type:"get",
			url:"http://jx.xuzhixiang.top/ap/api/productlist.php",
			data:{uid:"14632"},
			async:false,
			dataType:'json',
			success:function(data){
				console.log(data.data)
				_this.setState({plist:data.data})
				
			}
		})
	}

}


export default Productlist;
